package com.ss.android.newmedia.recommend;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.ss.android.common.app.AbsFragmentActivity;
import com.ss.android.gallery.comic.R;

public abstract class BaseRecommendActivity extends AbsFragmentActivity{
	public static final String BUNDLE_APP_NAME="app_name";
	public static final String BUNDLE_BANNER_DEFAULT_NAME="banner_default_name";
	public static final String BUNDLE_BANNER_DEFAULT_PACKAGE="banner_default_package";
	public static final String BUNDLE_BANNER_DEFAULT_URL="banner_default_url";
	public static final String BUNDLE_SCREEN_TYPE="screen_type";
	public static final String BUNDLE_TAG="tag";
	
	public static void setupDefaultArgs(Context context,Bundle bundle,String str){
		String s=RecommendThread.getScreenType(context);
		bundle.putString("tag", "recommend");
		bundle.putString("app_name", str);
		bundle.putString("screen_type", s);
		bundle.putString("banner_default_name", "funny");
		bundle.putString("banner_default_package", "com.ss.android.gallery.funny");
		bundle.putString("banner_default_url", "http://d.snssdk.com/funny.apk");
	}
	
	protected abstract BaseRecommendFragment getRecommendFragment();
	
	protected void init(){
		View view=findViewById(R.id.back);
		if(view!=null){
			view.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					BaseRecommendActivity.this.finish();
				}
			});
		}
		if(getSupportFragmentManager().findFragmentByTag("recommend_fragment")!=null){
			return;
		}
		BaseRecommendFragment fragment=getRecommendFragment();
		FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();
		transaction.add(R.id.fragment_container, fragment,"recommand_fragment");
		transaction.commit();
	}
	
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		requestWindowFeature(1);
		setContentView(R.layout.recommend_activity);
		init();
	}
}
